package com.ruoyi.web.controller.billSettings;


import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.EquipmentServiceBillingSettings;
import com.ruoyi.system.service.IEquipmentServiceBillingSettingsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备服务计费设置 Controller
 *
 * @author ruoyi
 * @date 2025-05-09
 */
@Api(tags="设备服务计费设置")
@RestController
@RequestMapping("/system/equipmentServiceBillingSettings")
public class EquipmentServiceBillingSettingsController extends BaseController
{
    @Autowired
    private IEquipmentServiceBillingSettingsService equipmentServiceBillingSettingsService;

    /**
     * 通过门店名称查询设备服务计费设置列表
     */
    @ApiOperation("通过门店名称查询设备服务计费设置列表")
    @PreAuthorize("@ss.hasPermi('system:settings:list')")
    @GetMapping("/list")
    public TableDataInfo list(@RequestParam(required = false) String storeName)
    {
        startPage();
        List<EquipmentServiceBillingSettings> list = equipmentServiceBillingSettingsService.selectEquipmentServiceBillingSettingsListByName(storeName);
        return getDataTable(list);
    }

    /**
     * 导出设备服务计费设置列表
     */
    @ApiOperation("导出设备服务计费设置列表")
    @PreAuthorize("@ss.hasPermi('system:settings:export')")
    @Log(title = "设备服务计费设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, @RequestParam(required = false) String storeName)
    {
        List<EquipmentServiceBillingSettings> list = equipmentServiceBillingSettingsService.selectEquipmentServiceBillingSettingsListByName(storeName);
        ExcelUtil<EquipmentServiceBillingSettings> util = new ExcelUtil<EquipmentServiceBillingSettings>(EquipmentServiceBillingSettings.class);
        util.exportExcel(response, list, "设备服务计费设置数据");
    }

    /**
     * 通过id获取设备服务计费设置详细信息
     */
    @ApiOperation("通过id获取设备服务计费设置详细信息")
    @PreAuthorize("@ss.hasPermi('system:settings:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(equipmentServiceBillingSettingsService.selectEquipmentServiceBillingSettingsById(id));
    }

    /**
     * 新增设备服务计费设置
     */
    @ApiOperation("新增设备服务计费设置")
    @PreAuthorize("@ss.hasPermi('system:settings:add')")
    @Log(title = "设备服务计费设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EquipmentServiceBillingSettings equipmentServiceBillingSettings)
    {
        return toAjax(equipmentServiceBillingSettingsService.insertEquipmentServiceBillingSettings(equipmentServiceBillingSettings));
    }

    /**
     * 修改设备服务计费设置
     */
    @ApiOperation("修改设备服务计费设置")
    @PreAuthorize("@ss.hasPermi('system:settings:edit')")
    @Log(title = "设备服务计费设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EquipmentServiceBillingSettings equipmentServiceBillingSettings)
    {
        return toAjax(equipmentServiceBillingSettingsService.updateEquipmentServiceBillingSettings(equipmentServiceBillingSettings));
    }

    /**
     * 通过id批量删除设备服务计费设置信息
     */
    @ApiOperation("通过id批量删除设备服务计费设置信息")
    @PreAuthorize("@ss.hasPermi('system:settings:remove')")
    @Log(title = "设备服务计费设置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(equipmentServiceBillingSettingsService.deleteEquipmentServiceBillingSettingsByIds(ids));
    }
}
